<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
	response.setHeader("Pragma", "No-Cache");
	response.setHeader("Cache-Control", "No-Cache");
	response.setDateHeader("Expires", 0);
	String recipeid=request.getParameter("recipeid")==null?null:request.getParameter("recipeid");
%>
<!DOCTYPE html PUBLIC "-//W3C//Dtd XHTML 1.0 Transitional//EN" "http://www.w3.org/tr/xhtml1/Dtd/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
		<title>药典管理-疾病处方明细</title>
		<link type="text/css" rel="stylesheet"
			href="${pageContext.request.contextPath}/drugUI/css/style.css" />
		<link type="text/css" rel="stylesheet"
			href="${pageContext.request.contextPath}/drugUI/css/main.css" />
		<script type="text/javascript"
			src="${pageContext.request.contextPath}/drugUI/js/util.js"></script>
		<script type="text/javascript"
			src="${pageContext.request.contextPath}/drugUI/js/jquery1.4.2.min.js"></script>
	</head>
	<body style="overflow-x: hidden; overflow-y:auto;">
		<div id="container">
			<form name="Form1" method="post" id="Form1">
				<!--查询栏 开始-->
				<div class="current">
					<div class="current_con">
						<div class="help">
							<a href="#"><img
									src="${pageContext.request.contextPath}/drugUI/image/help.gif"
									title="帮助"
									onclick="showLayer('C5','${pageContext.request.contextPath}')" />
							</a>
						</div>
						<span>_当前位置：</span> 药典管理 >>疾病管理 >>疾病处方明细
					</div>
				</div>
				<table class="table02"  align="center">
					<tr>
						<td class="td_bottom" align="center" colSpan="7">
						<input type="button" name="btnDelete" value="删除"
								onClick="javascript:del();" id="btnDelete" class="btn02" />
							&nbsp;
						<input type="button" name="btnBack" value="关 闭"
									onclick="javascript: closeWindow();" id="btnBack" class='btn02' />
						</td>
					</tr>
				</table>
				<!--列表输出-->
				<div id="content">
					<div id="tabContainer">
						<!--列表输出表头-->
						<!--列表输出表头-->
						<div id="tabTitle">
						<table width="100%" class="table01" align="center" cellspacing="0">
							<tr align="center" class="tr_title">
									<td width="5%" height="30" scope="col">
										<input id='cbSelectAll' name='cbSelectAll' type='checkbox'
											onclick="selectOrCancelBox( 'cbSelectAll', 'ids' );" />
									</td>
									<td width="20%" scope="col">
										药品名称
									</td>
									<td width="15%" scope="col">
										单位
									</td>
									<td width="15%" scope="col">
										剂量
									</td>
									<td width="15%" scope="col">
										频次
									</td>
									<td width="15%" scope="col">
										天数
									</td>
									<td width="15%" scope="col">
										说明
									</td>
								</tr>
							</table>
						</div>
						<!--列表输出各行数据-->
						<div id="tabLines">
							<table class="table01" width="100%"
								style="TABLE-LAYOUT: fixed; word-break: break-all"
								align="center" cellspacing="0">
								<tbody id="__list">
									<c:forEach items="${recipedetails}" var="s" varStatus="i">
										<tr <c:if test="${i.index%2==0}"> class = 'tr_1'</c:if>
											<c:if test="${i.index%2==1}"> class = 'tr_2'</c:if>>
											<td width="5%" scope="col">
												<input name='ids' type='checkbox'
													value="${ s.id }" />
											</td>
											<td width="20%">
											<a href="#" onClick="javascript:showHandleDialog( 'edit','${s.drugid}' )">${s.drugname}</a>
											</td>
											<td width="15%">
												${s.unit}
											</td>
											<td width="15%">
												${s.dosage}
											</td>
											<td width="15%">
												${s.frequency }
											</td>
											<td width="15%">
												${s.days}
											</td>
											<td width="15%">
												${s.tips }
											</td>
										</tr>
									</c:forEach>
								</tbody>
							</table>
						</div>
					</div>
				</div>
			</form>
		</div>
		<script language="javascript">
		function reflush( pageNum )
		{
			$.ajax({
		        "url": "recipe.queryRecipeDetails.action",
		        "data": 
		        { 
		        	"pageNum": pageNum,
		        	"recipeid":<%=recipeid%>
		        },
		        "dataType": "json",
		        "type": "POST",
		        "success": function( obj )
		        { 	
					$("#__list").empty();
					if(obj!=null)
					{
					$.each(obj.statisticsList, function(index, s){
							var trObj = $("<tr></tr>");
							trObj.attr("align","center");  
		                    $("<td  width=\"5%\"></td>").html( "<input type=\"checkbox\" name=\"ids\" value='"+ s.id +"' />").appendTo(trObj);    
		                    $("<td  width=\"20%\"></td>").html("<a href=\"#\" onClick=\"javascript:showHandleDialog( 'edit','"+s.drugid+"' )\">"+s.drugname+"</a>" ).appendTo(trObj);
		                    $("<td  width=\"15%\"></td>").html(s.dosage).appendTo(trObj); 
		                    $("<td  width=\"15%\"></td>").html(s.unit ).appendTo(trObj);
		                    $("<td  width=\"15%\"></td>").html(s.frequency).appendTo(trObj);
		                    $("<td  width=\"15%\"></td>").html(s.days).appendTo(trObj);
		                    $("<td  width=\"15%\"></td>").html(s.tips).appendTo(trObj);
		                    trObj.appendTo($("#__list")); 
		                    $('tbody[id*=__list] > tr:even').addClass('tr_1');
		                    $('tbody[id*=__list] > tr:odd').addClass('tr_2');
		                    $('tbody[id*=__list] > tr[id!=totalRow]').mouseover(function(){$(this).removeClass();$(this).addClass('tr_0');})
		                    $('tbody[id*=__list] > tr[id!=totalRow]:even').mouseout(function(){$(this).addClass('tr_1');})
		                    $('tbody[id*=__list] > tr[id!=totalRow]:odd').mouseout(function(){$(this).addClass('tr_2');})
		            });
					}
		        }
		    });
		}
		function showHandleDialog(action,planId){
			var url= "${pageContext.request.contextPath}/drugUI/drug/drug.edit.action?type=edit&drugid="+planId;
			returnValue = modelWindow(url,768,300);
		}
		function closeWindow() {
		window.close();
	}
		function del(recipeId)
		{
		var pprcd = getCheckBoxValues("ids");
			if ( pprcd == "")
			{
				alert( "请选择需要删除的记录!" );
				return false;
			}
			if( !confirm( "您确定要删除选定的记录吗？" ) )
				return;
			$.ajax({
			    'url': 'recipe.deleteRecipeDetails.action',
			    'data': {'ids':pprcd},
			    'dataType': 'text',
			    'type': 'POST',
			    'success': function( flag )
			    {
			    	if ( flag == '0' )
			    	{
			    		reflush('1');
			    		alert("删除成功！");	
			    	}
			    	else
			    	{
			    	     alert("删除失败，请重新阐述或者联系管理员！");
			    	}
				}
		   });
		}
		window.onload = function(){resizeTabBody( 'tabLines' )};
		window.onresize = function(){resizeTabBody( 'tabLines' )};
	</script>
	</body>
</html>
<%@ include file="/drugUI/common/footer.jsp"%>
